The data used for this analysis comes from the Office of Spill Prevention and Response (OSPR) Incident Tracking Database which is a state-wide oil spill tracking information system with quantified statistical data. The data is collected by OSPR Field Response Team, OSPR Inland Pollution Coordinaters, and Wardens depending on the location of the incident. The data used is of 2008 recorded oil spill incidents (both marine and inland). Also, data outlining California counties is used and comes from the US Census Bureau’s 2016 MAF/TIGER database. Using two different mapping methods, this analysis first provides an interactive visualization of individual oil spill incidents in California. Secondly, the counties in California most affected by inland oil spills (number of oil spill incidents) is determined and visually displayed in a thematic map.
Data citation: California Department of Fish and Game, Office of Spill Prevention and Response. 2009. Oil Spill Incident Tracking [ds394]. accessed: https://map.dfg.ca.gov/metadata/ds0394.html
US Census Bureau 2016 MAF/TIGER. California Open Data Portal. accessed: https://data.ca.gov/dataset/ca-geographic-boundaries/resource/b0007416-a325-4777-9295-368ea6b710e6?inner_span=True
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
# Set code chunk options and attach necessary pkgs
library(tidyverse)
library(here)
library(broom)
library(sf)
library(tmap)
# Read in the data
oil_spills_sf <- read_sf(here("data/ds394/ds394.shp")) %>%
janitor::clean_names()
ca_counties_sf <- read_sf(here("data/CA_Counties_TIGER2016.shp")) %>%
janitor::clean_names()
Code is wrangled to simplify shape files of both ca_counties_sf and oil_spills_sf. Coordinate reference systems (CRS) are adjusted to match b/w the two datasets. Two maps that show the distribution of oil spills in California and among counties are the outcome of this data wrangling.
ca_subset_sf <- ca_counties_sf %>%
select(county_name = name, land_area = aland)
# Look at coordinate reference system of the ca_subset_sf, change code chunk option so long result isn't shown in knitted doc
ca_subset_sf %>% st_crs() # take simple feature obj and get CRS information
ca_subset_sf %>% raster::crs() # crs = 3857
# Look at CRS for the oil_spills_sf
oil_spills_sf %>% st_crs() # take simple feature obj and get CRS information
oil_spills_sf %>% raster::crs()
# It is different than the CA subset so change to 3857
### We know the EPSG code so we can use the following code:
spills_3857_sf <- st_transform(oil_spills_sf, 3857)
# Checking to make sure it worked:
spills_3857_sf %>% st_crs()
# Set the viewing mode to "interactive":
tmap_mode(mode = "view")
# Then make a map with `ca_subset_sf` as first shape and then add `oil_spills_sf` as second shape
tm_shape(ca_subset_sf) +
tm_polygons(col = "sienna", alpha = 0.5, border.col = "white") +
tm_shape(oil_spills_sf) +
tm_dots(col = "sienna", border.col = "sienna", size = 0.01)